 /*
  * Copyright (c) 2021, 2023, yishun.cn All rights reserved.
  *
  */
 package cn;

 import cn.shun.config.SpringConfig;
 import cn.shun.entity.Student;
 import cn.shun.mapper.StudentMapper;
 import cn.shun.vo.StudentVo;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

 import java.util.HashMap;
 import java.util.Map;

 /**
  * <p>Project: MyBatis2023 - StudentDemo
  * <p>Powered by yishun On 2023-01-30 11:07:19
  *
  * @author yishun [2465734101@qq.com]
  * @version 1.0
  * @since 17
  */
 @SpringJUnitConfig(SpringConfig.class)
 public class StudentDemo {
     @Autowired
     StudentMapper sm;

     @Test
     @DisplayName("save 实体类")
     void insert() {
         Student student = new Student();
         student.setName("Tom");
         int i = sm.add(student);
         //返回主键
         System.out.println(student.getId());
         if (i > 0) {
             System.out.println("插入成功");
         }
     }
     @Test
     @DisplayName("save Map")
     void insert2() {
         Map<String,Object> map=new HashMap<>();
         map.put("name","jack");
         int i = sm.save(map);
         System.out.println(map.get("id"));
         if (i > 0) {
             System.out.println("插入成功");
         }
     }
     @Test
     @DisplayName("insert Map")
     void insert3() {
         Map<String,Object> map=new HashMap<>();
         map.put("name","song");
         int i = sm.insert(map);
         System.out.println(map.get("sid"));
         if (i > 0) {
             System.out.println("插入成功");
         }
     }
     @Test
     @DisplayName("insert 实体类")
     void insert4() {
         StudentVo vo=new StudentVo();
         vo.setName("李华");
         int i = sm.insert(vo);
         if (i > 0) {
             System.out.println("插入成功");
         }
     }
 }
